package com.longjianghuasheng.logistics.ext

import android.content.Context
import android.os.Looper
import com.tencent.map.geolocation.TencentLocation
import com.tencent.map.geolocation.TencentLocationListener
import com.tencent.map.geolocation.TencentLocationManager


inline fun Context.getLocation(crossinline block: (TencentLocation?) -> Unit) {


    requestLocationPermission {

        TencentLocationManager.getInstance(this).requestSingleFreshLocation(
            null,
            object : TencentLocationListener {
                override fun onLocationChanged(location: TencentLocation?, p1: Int, p2: String?) {
                    block.invoke(location)
                }

                override fun onStatusUpdate(p0: String?, p1: Int, p2: String?) {

                }
            }, Looper.getMainLooper()
        )

    }


}